#include <iostream>
#include <fstream>
#include <vector>
#include <chrono>

void bubble_sort(std::vector<int>& a) {
    for (int i = 0; i < a.size() - 1; i++) {
        for (int j = 0; j < a.size() - i - 1; j++) {
            if (a[j] > a[j + 1]) {
                std::swap(a[j], a[j + 1]);
            }
        }
    }
}

int main() {
    std::vector<std::string> f = {"m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"};
    for (const std::string& file : f) {
        std::ifstream input(file);
        std::vector<int> b;
        int line;
        while (input >> line) {
            b.push_back(line);
        }
        input.close();
        auto start_time = std::chrono::high_resolution_clock::now();
        bubble_sort(b);
        auto end_time = std::chrono::high_resolution_clock::now();
        int duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count();
        std::string file_name = file.substr(0, file.find('.'));
        std::cout << file_name << " " << duration << " milliseconds" << std::endl;
    }
    return 0;
}
